package actions;

import java.util.ArrayList;
import java.util.List;

import model.VadeMecumMultimedia;
import persistence.VadeMecumMultimediaDAO;

import com.opensymphony.xwork2.ActionSupport;

public class QueryUsingXPathAction extends ActionSupport {

	private String XPathExpression;
	
	private String locationPoint;
		
	private String radius;
	
	//TODO depois provavelmente devera ser lista de files!
	private List<VadeMecumMultimedia> results;
	
	public String execute() throws Exception {

		try {
			//TODO
			System.out.println("Chegou no execute!");
			results = VadeMecumMultimediaDAO.getInstance().getTheseFiles(getXPathExpression(), getLocationPoint(), getRadius());
			
			//TODO for test
//			results = new ArrayList<VadeMecumMultimedia>();
//			results.add(new VadeMecumMultimedia(new File("C:\\Documents and Settings\\winxp\\workspace\\VadeMecumMultimediaService\\teste\\consultas\\situationExample.xml"), "//test1/test1.jpg"));
//			results.add(new VadeMecumMultimedia(new File("C:\\Documents and Settings\\winxp\\workspace\\VadeMecumMultimediaService\\teste\\consultas\\situationExample.xml"), "//test2/test2.jpg"));
			
			//TODO
//			System.out.println("Com results ja!");
		} catch (Exception e) {
			
			addActionError(e.getMessage());

			return INPUT;

		}

		return SUCCESS;

	}

	public String getXPathExpression() {
		return XPathExpression;
	}

	public void setXPathExpression(String pathExpression) {
		XPathExpression = pathExpression;
	}

	public String getLocationPoint() {
		return locationPoint;
	}

	public void setLocationPoint(String locationPoint) {
		this.locationPoint = locationPoint;
	}

	public String getRadius() {
		return radius;
	}

	public void setRadius(String radius) {
		this.radius = radius;
	}
		
	public List<VadeMecumMultimedia> getResults() {
		return results;
	}

	public void setResults(List<VadeMecumMultimedia> results) {
		this.results = results;
	}

	

}